/***
 * @Author: 玄绮 shijiahansi@qq.com
 * @Date: 2024-06-08 07:55:50
 * @LastEditors: 玄绮 shijiahansi@qq.com
 * @LastEditTime: 2024-06-08 08:08:57
 * @FilePath: \server\test\split\main.cpp
 * @Description:
 * @
 * @Copyright (c) 2024 by 玄绮, All Rights Reserved.
 */
#include <boost/algorithm/string/erase.hpp>
#include <fstream>
#include <iostream>
#include <string_view>
#include <vector>
#include <stringsplit.h>

using namespace std;

const string boundary = "boundary_.oOo._FrxtKGRGRBagNnfck20HOYm2ZqWTI5th";
int main(int argc, char const* argv[]) {
    std::ifstream fin("test.body", ios::binary);

    // 或者使用 std::string 直接读取文件内容
    std::string content((std::istreambuf_iterator<char>(fin)), std::istreambuf_iterator<char>());

    content.erase(0, boundary.size() + 4);
    // content.erase(0, boundary.size() + 4);
    boost::erase_all(content, "\r\n--" + boundary + "--\r\n");

    // str.find("--" + boundary);
    auto list = split(content, "--" + boundary);

    for (auto&& i : list) {
        cout << i << endl;
        
    }

    return 0;
}
